module AI where

import Evaluator2
import GameLoop

import Pruning

import System.Random
import System.IO

type Turn = Int
type AI = GameState -> Turn -> [App] -> IO App


stupid_ai :: AI
stupid_ai state k turns = do
--         hPutStrLn stderr $ show state
         return $ RightApp 0 I

program = map ( <$ Inc) [0..9]

alpha_ai :: AI
alpha_ai state k _ | k < length program = return $ program !! k
                   | True = do
  let best = bestApplications state
  r <- getStdRandom (randomR (0,length best - 1))
  let move = best !! r
--  hPutStrLn stderr $ "@@@ state = " ++ show state
--  hPutStrLn stderr $ "@@@ moves = " ++ show best
  hPutStrLn stderr $ "@@@ turn " ++ show k
  hPutStrLn stderr $ "@@@ chosed move " ++ show move ++ " from " ++ show (length best) ++ " best"
  return $ fst move